$op = shift @ARGV;
if(!defined($op)){
    print "No se definio operacion a realizar\n";
    exit;
}

if($op eq "-new"){
    $type = shift @ARGV;

    if(!defined($type)){
	print "Faltan argumentos\n";
    }else{

	if($type eq "op"){
	    my $opname = shift @ARGV;
	    if(!defined($opname)){
		print "Falta el nombre\n";
		exit;
	    }
	    my $name = "Operations/".$opname.".pm";
	    open FILE, ">".$name;
	    print FILE "use Operation;\n";
	    print FILE "\n";
	    print FILE "package ".$opname.";\n";
	    print FILE "\@ISA=qw/Operation/;\n";
	    print FILE "\n";
	    print FILE "sub init{\n";
	    print FILE "\tmy \$self = shift;\n";
	    print FILE "\t\$self->dependencies(qw//);\n";
	    print FILE "}\n";
	    print FILE "\n";
	    print FILE "sub perform{\n";
	    print FILE "\tmy \$self = shift;\n";
	    print FILE "\treturn ActionResult->new(\"SUCCESS\", \"OK\");\n";
	    print FILE "}\n";
    	    print FILE "\n";
	    print FILE "1;";
	    
	    close FILE;

	    open FILE, ">>Operations.pm";
	    print FILE "use Operations::".$opname.";\n";
	    print FILE "1;";
	    close FILE;
	}else{
	    print "Tipo incorrecto\n";
	}

    }
}else{
    print "Operacion incorrecta\n";
}

